package top.ligongzi.hrm.config;

import top.ligongzi.hrm.contstants.AuthConstants;
import top.ligongzi.hrm.exception.ErrorCode;
import top.ligongzi.hrm.exception.ValidUtils;
import top.ligongzi.hrm.vo.Oauth2ClientDetails;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Configuration
@ConfigurationProperties(prefix = "oauth2.client") //从配置文件中读取以oauth2.client打头的配置
@Data
public class Oauth2ClientDetailsProperties {
    private Oauth2ClientDetails website;
    private Oauth2ClientDetails system;

    //通过类型获取我们要用的是那种客户端
    public Oauth2ClientDetails getClientDetials(Integer type) {
        ValidUtils.assertNotNull(type, "请输入对应类型！");
        switch (type.intValue()){
            case AuthConstants.LOGIN_TYPE_ADMIN : return system;
            case AuthConstants.LOGIN_TYPE_USER : return website;
        }
        return null;
    }
}